package trb.complexshield.bool;

import no.hrp.hvrc.rad.calc.intersect.Segment;

public class BoxSegments implements SegmentsProducer {

    private IntersectableBox box;

    public BoxSegments(IntersectableBox box) {
        this.box = box;
    }

    @Override
    public Segments getSegments(Segment line, Segments out, SegmentsMemory memory) {
        out.clear();
        float[] tMinMax = new float[2];
        if (box.intersects(line, tMinMax)) {
            out.addAtEnd(tMinMax[0], tMinMax[1]);
        }
        return out;
    }
}
